% 内生、外生变量声明，z即为lambda
var c k h r z y;
varexo e;
parameters beta delta theta A rho;
beta = 0.99;
delta = 0.025;
theta = 0.36;
A = 1.72;
rho = 0.95;

% 方便后面为求稳态的初值赋值
parameters Hss Kss;
Hss = 1/(1+A/(1-theta) * (1-beta*delta*theta/(1-beta*(1-delta))));
Kss = Hss*(theta/(1/beta - 1+delta))^(1/(1-theta));

model;
1 - beta*((c/c(+1))*(r(+1)+1-delta));
c = (1/A)*(1-h)*(1-theta)*y/h;
k = y -c + (1-delta)*k(-1);
y = z*(k(-1)^theta)*(h^(1-theta));
r = theta*y/k(-1);
log(z) = rho*log(z(-1))+e;
end;

initval;
k = Kss;
h = Hss;
y = Kss^theta*Hss^(1-theta);
c =  y - delta*Kss;
r = theta*y/Kss;
z = 1;
e = 0;
end;

steady;
resid;

stoch_simul;